package main

import (
	"net"
	"fmt"
	"os"
)

func main()  {
	tcpAddr,_:=net.ResolveTCPAddr("tcp",":5555")
	listener,_:=net.ListenTCP("tcp",tcpAddr)
	conn,_:=listener.Accept()
	bs:=make([]byte,1024)
	destname:="/home/xiaonu/Desktop/bb.png"
	file1,_:=os.OpenFile(destname,os.O_RDWR|os.O_CREATE,os.ModePerm)

	for {
		n,_:=conn.Read(bs)
		fmt.Println(n)
		file1.Write(bs[:n])
		if n==0 {

			break
		}
		fmt.Println(bs[:n])


	}

}

